package com.nuanshui.framework.springContext;

import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
 * Created by zxh on 2017/1/4.
 */
public class SpringPropertiesUtil {

    private static Properties configProperties;

    public void setPropertyConfigurer(Properties propertyConfigurer) {
        configProperties = propertyConfigurer;
    }

    public static String getPropertiestValue(final String name) {
        if(configProperties!=null)
           return configProperties.getProperty(name);

        return "";
    }

    public static String getPropertiestValueByDecode(final String name) {
        if(configProperties!=null)
        {
            String temp =  configProperties.getProperty(name);

            if(temp == null) return "";
            try {
                String value = new String(temp.getBytes("iso-8859-1"), "utf-8");
                return value;
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return "";
    }
}
